package com.mk.admin.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.vo.*;
import com.mk.admin.service.PayService;
import com.mk.admin.util.HttpTool;
import org.springframework.stereotype.Service;

@Service
public class PayServiceImpl implements PayService {
    @Override
    public ResultDto patientRegisterBudget(PatientRegisterBudgetVo vo) {
        JSONObject jsonObject = HttpTool.postJson("stt_0001", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"[]".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto patientRegisterSettlement(PatientRegisterSettlementVo vo) {
        JSONObject jsonObject = HttpTool.postJson("stt_0002", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"[]".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto patientFeeBudget(PatientFeeBudgetVo vo) {
        JSONObject jsonObject = HttpTool.postJson("stt_0003", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"[]".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto patientFeeSettlement(PatientFeeSettlementVo vo) {
        JSONObject jsonObject = HttpTool.postJson("stt_0004", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"[]".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto patientRegisterReturnNo(PatientRegisterReturnNoVo vo) {
        JSONObject jsonObject = patientRegisterReturnNoJson(vo);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    public JSONObject patientRegisterReturnNoJson(PatientRegisterReturnNoVo vo) {
        return HttpTool.postJson("stt_0007", vo);
    }

    @Override
    public ResultDto patientRegisterReturnMoney(PatientRegisterReturnMoneyVo vo) {
        JSONObject jsonObject = patientRegisterReturnMoneyJson(vo);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public JSONObject patientRegisterReturnMoneyJson(PatientRegisterReturnMoneyVo vo) {
        return HttpTool.postJson("stt_0006", vo);
    }

    @Override
    public ResultDto patientRegisterReturnMoneyResult(PatientRegisterReturnMoneyResultVo vo) {
        JSONObject jsonObject = patientRegisterReturnMoneyResultJson(vo);
        Object result = jsonObject.get("result");
        if (result != null) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @Override
    public JSONObject patientRegisterReturnMoneyResultJson(PatientRegisterReturnMoneyResultVo vo) {
        return HttpTool.postJson("stt_0008", vo);
    }
}
